package com.bupt.controller;

import com.bupt.bean.DeviceTypeAttribute;
import com.bupt.config.DeviceTypeAttributeResult;
import com.bupt.config.Result;
import com.bupt.service.DeviceService;
import com.bupt.vo.SysConst;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Api(value="设备属性和通道属性接口",description="设备属性和通道属性的增删改查、属性类型、配置开关和设备开关")
@RestController
public class DeviceTypeAttributeController {

    @Autowired
    private DeviceService deviceService;


    @ApiImplicitParams({@ApiImplicitParam(name = "deviceTypeId", value = "设备类型ID", required = true, paramType = "path", dataType = "int"), @ApiImplicitParam(name = "attributeBigType", value = "设备属性传1,通道属性传2", required = true, paramType = "path", dataType = "int")})
    @ApiOperation("根据设备类型ID和大类查询设备属性或通道属性")
    @GetMapping("/deviceTypeAttributePage/{deviceTypeId}/{attributeBigType}")
    public List deviceTypeAttributePage(@PathVariable("deviceTypeId") Integer deviceTypeId,@PathVariable("attributeBigType") Integer attributeBigType) {
        return deviceService.findDeviceTypeAttributeList(deviceTypeId,attributeBigType);
    }

    @ApiOperation("通过ID删除设备属性或通道属性")
    @DeleteMapping("/deviceTypeAttribute/deleteById/{deviceTypeAttributeId}/{attributeBigType}")
    public Result deviceTypeAttribute(@PathVariable("deviceTypeAttributeId") Integer deviceTypeAttributeId,@PathVariable("attributeBigType") Integer attributeBigType) {
        return deviceService.deleteDeviceTypeAttributeById(deviceTypeAttributeId,attributeBigType);
    }

    @ApiOperation("添加设备属性或通道属性")
    @PutMapping("/deviceTypeAttribute/{deviceTypeId}/{attributeBigType}")
    public DeviceTypeAttributeResult addDeviceTypeAttribute(@PathVariable("deviceTypeId") Integer deviceTypeId, @PathVariable("attributeBigType") Integer attributeBigType, @RequestBody DeviceTypeAttribute deviceTypeAttribute) {
        return deviceService.addDeviceTypeAttribute(deviceTypeId,attributeBigType,deviceTypeAttribute);
    }

    @ApiOperation("通过ID修改设备属性或通道属性")
    @PostMapping("/deviceTypeAttribute/edit/{deviceTypeAttributeId}/{attributeBigType}")
    public DeviceTypeAttributeResult editDeviceTypeAttribute(@PathVariable("deviceTypeAttributeId") Integer deviceTypeAttributeId, @PathVariable("attributeBigType") Integer attributeBigType,@RequestBody DeviceTypeAttribute deviceTypeAttribute) {
        return deviceService.editDeviceTypeAttribute(deviceTypeAttributeId,attributeBigType,deviceTypeAttribute);
    }


    @ApiOperation("属性类型")
    @GetMapping("/deviceTypeAttribute/attributeType")
    public List<SysConst> attributeType() {
        return deviceService.attributeType();
    }

    @ApiOperation("配置开关")
    @GetMapping("/deviceTypeAttribute/configStatus")
    public List<SysConst> configStatus() {
        return deviceService.configStatus();
    }

    @ApiOperation("设备开关")
    @GetMapping("/deviceTypeAttribute/enableDevice")
    public List<SysConst> enableDevice() {
        return deviceService.enableDevice();
    }
}
